/*______________________________________________________________________________
 *
 * Copyright 2005 NORSYS
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * (1) Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 * (2) Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 * (3) The name of the author may not be used to endorse or promote
 *     products derived from this software without specific prior
 *     written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *______________________________________________________________________________
 *
 * Created on 27 sept. 2005
 * Author: Arnaud Bailly
 */
package speculoos.manager;


import speculoos.core.Mapper;
import speculoos.core.MapperException;

/**
 * Interface for business mapper operations.
 * The basic life-cycle of the manage interface is the following :
 * <ol>
 * <li>The manager is created,</li>
 * <li>The manager is initialized with mappers, connections and parameters
 * using the appropriate methods {@link Configure},</li>
 * <li>The manager is put into ready state with method {@link #start()}. This
 * method does allocate the necessary resources for the manager to operate,
 * </li>
 * <li>The manager provides mappers through the {@link #getMapper(String)}
 * method,</li>
 * <li>The manager is shutdown by method {@link #stop()}and properly release
 * its resources. It must then be restarted.</li>
 * </ol>

 * @author nono
 * @version $Id:Manage.java 124 2005-11-02 17:05:40 +0100 (Wed, 02 Nov 2005) /C=FR/ST=Nord/L=Lille/O=Norsys SA/OU=UE/CN=Arnaud Bailly/emailAddress=abailly@norsys.fr $
 */
public interface Manage {

    /**
	 * Starts operating the manager.
     * This method is idempotent: Once called, further invocations should have no 
     * further side effects.
     * @throws MapperException
	 * 
	 */
	public abstract void start() throws MapperException ;

	/**
	 * Returns the mapper associated with the given name in this manager.
	 * 
	 * @param name name identifying mapper. May not be null.
	 * @return a mapper that is ready to operate.
	 * @throws MapperConfigurationException
	 */
	public abstract Mapper getMapper(String name) throws MapperException;

	/**
	 * Releases a mapper object which allows clean up and reuse 
	 * of its associated resources.
	 * 
	 * @param mapper the mapper object to release.
	 */
	public abstract void release(Mapper mapper) throws MapperException;

	/**
	 * Stops the manager.
	 * This method is idempotent: Once called, further invocations should have no 
     * further side effects.
	 */
	public abstract void stop();

    /**
     * Lookup parameter name in this context. First name is looked up in
     * <code>environment</code>, if not found, it is looked up in
     * <code>parameters</code>. If not found, an exception is thrown.
     * 
     * @param param
     *            the name of the parameter to look up
     * @return value of this parameter in this environment
     * @throws MapperException
     *             if <code>param</code> is not defined in this context.
     */
    public Object lookup(String param) throws MapperException;

}